package com.conversationboard.model.adminlog;

import java.sql.SQLException;
import java.sql.Timestamp;

import com.conversationboard.model.Boards;
import com.conversationboard.model.User;

public class AdminLogEntry {

	private int id;
	private int boardId;
	private String action;
	private Timestamp timestamp;
	private String reason;
	private String loginId;
	private String displayName;


	public Timestamp getTimestamp() {
		return timestamp;
	}


	public void setTimestamp(Timestamp timestamp) {
		this.timestamp = timestamp;
	}


	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	public int getBoardId() {
		return boardId;
	}


	public void setBoardId(int boardId) {
		this.boardId = boardId;
	}


	public String getAction() {
		return action;
	}


	public void setAction(String action) {
		this.action = action;
	}


	public String getReason() {
		return reason;
	}


	public void setReason(String reason) {
		this.reason = reason;
	}


	public boolean isAuthorised(User user) throws SQLException {

		if (this.boardId != 0) {
			if (user.canRead(this.boardId)) {
				return true;
			} else {
				return false;
			}
		}

		return true;
	}


	public String getBoardName(User user) throws SQLException {

		if (this.boardId != 0) {
			if (this.isAuthorised(user)) {
				return Boards.getBoard(boardId).getName();
			}
		}

		return "Site";
	}


	public String getLoginId() {
		return loginId;
	}


	public void setLoginId(String loginId) {
		this.loginId = loginId;
	}


	public String getDisplayName() {
		return displayName;
	}


	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

}
